<?php
class UserIdBehavior extends CActiveRecordBehavior {
 
  /**
   * The field that stores the modification time
   */
  public $userId = 'userId';
 
  public function beforeValidate() {

    $this->Owner->{$this->userId} = Yii::app()->user->id;
    return true;    

  }

}
